<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <th:block th:insert="common/fragment :: icon"></th:block>
    <title>分类新增</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <!-- markdown编辑插件 -->
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css"
          th:href="@{/lib/editormd/css/editormd.min.css}"/>
    <link rel="stylesheet" href="../../static/css/me.css" th:href="@{/css/me.css}">
</head>

<body>
    <!-- 导航栏部分 -->
    <nav th:replace="common/admin-frag :: firstmenu(3)"></nav>
    <!-- 二级导航 -->
    <div th:replace="common/admin-frag :: secondmenu(1,~{::#a1},~{::#a2})">
        <a id="a1" href="#" th:href="@{/admin/types/input}" class="item" th:classappend="${n==1} ? 'teal active'">新增</a>
        <a id="a2" href="#" th:href="@{/admin/types}" class="item" th:classappend="${n==2} ? 'teal active'">列表</a>
    </div>
    <br>
    <br>
    <!-- 中间部分 -->
    <div class="m-container-small m-padded-tb-big">
        <div class="ui container">
            <form action="#" th:object="${tag}" th:action="*{id}==null ? @{/admin/tags} : @{/admin/tags/{id}(id=*{id})}" method="POST" class="ui form">
                <input type="hidden" name="id" th:value="*{id}">
                <div class="required field">
                    <div class="ui left labeled input">
                        <label class="ui teal basic label">名称</label>
                        <input type="text" name="name" placeholder="标签名称" th:value="*{name}">
                    </div>
                </div>
                <div class="ui error mini message"></div>
                <!--thymeleaf自带的注释，会自动识别，符合判断条件可以显示-->
                <!--/*/
                <div class="ui negative message" th:if="${#fields.hasErrors('name')}">
                    <i class="close icon"></i>
                    <div class="header">验证失败</div>
                    <p th:errors="*{name}">提交的信息不符合规则</p>
                </div>
                /*/-->
                <div class="ui right aligned container">
                    <button class="ui button" onclick="window.history.go(-1)">返回</button>
                    <button class="ui teal submit button">提交</button>
                </div>
            </form>
        </div>
    </div>
    <br>
    <br>
    <br>
    <br>
    <!-- 底部部分 -->
    <footer th:replace="common/fragment :: footer"></footer>


    <!-- js模块 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
    <script src="../../static/lib/editormd/editormd.min.js" th:src="@{/lib/editormd/editormd.min.js}"></script>
    <script src="../../static/js/me.js" th:src="@{/js/me.js}"></script>

    <script>
        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('m-mobile-hide'); /* 记住不用加点 */
        });
        // 账号下拉列表
        $('.ui.dropdown').dropdown();
        //表单验证
        /*$('.ui.form').form({
            fields : {
                name : {
                    identifier: 'name',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入分类名称！'
                    }]
                }
            }
        });*/
        //关闭操作提示的初始化
        $('.message .close').on('click', function () {
            $(this).closest('.message').transition('fade');/*fade:褪色，会慢慢的关闭*/
        });
    </script>
</body>

</html>